package com.dcc.inventory.interceptor;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class SessionConfiguration1 implements WebMvcConfigurer {
    //配置拦截器
    //白名单
    String[] whiteList = {
            "/**/login.html",
            "/**/img/**",
            "/**/*.css",
            "/**/*.png",
            "/**/*.js",
            "/**/login/**",
            "/**/searchAuth/**",
            "/**/authLogin/**",
            "/**/bootstrap/**",
            "/**/*.woff2",
            "/**/*.woff",
            "/**/*.ttf",
            "/**/temporary_pdf/**",
            "/**/ProMgProject/HtmlToPDF",
            "/**/error/*.html",
            "/*.ico",
            "/websocket/**"};

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        LoginInterceptor loginInterceptor = new LoginInterceptor();
        InterceptorRegistration loginRegistry = registry.addInterceptor(loginInterceptor);
        loginRegistry.addPathPatterns("/**");
        //白名单
        for (String s : whiteList) {
            loginRegistry.excludePathPatterns(s);
        }
    }
}
